package com.weixing.mall.provider.model.excel;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.weixing.mall.base.constant.DatePattern;
import com.weixing.mall.base.constant.GlobalConstant;
import com.weixing.mall.provider.api.model.enums.OrderTypeEnum;
import com.weixing.mall.provider.model.enums.AfterSaleAuditEnum;
import com.weixing.mall.provider.model.enums.AfterSaleIsHandleEnum;
import com.weixing.mall.provider.model.enums.AfterSalesTypeEnum;
import com.weixing.mall.provider.model.enums.OrderStateEnum;
import lombok.Data;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 * @author 0202
 * @date 2020-8-21
 * @Version 1.0
 **/
@Data
@ContentRowHeight(100)
public class AfterSaleProblemED {

    @ExcelProperty("支付流水号")
    private String outTradeNo;
    @ExcelProperty("订单编号")
    private String orderSn;
    @ExcelProperty("商品名称")
    private String productName;
    @ExcelProperty("图片")
    @ExcelIgnore
    private String img;
    @ExcelProperty("图片")
    private URL imgUrl;
    @ExcelProperty("货号")
    private String goodsSn;
    @ExcelProperty("款号")
    private String styleNo;
    @ExcelProperty("颜色/尺码")
    @ExcelIgnore
    private String productSkuDesp;
    @ExcelProperty("颜色")
    private String color;
    @ExcelProperty("尺码")
    private String size;
    @ExcelProperty("收货人")
    private String contactUser;
    @ExcelProperty("收货人手机号")
    private String contactPhone;
    @ExcelProperty("下单人")
    private String buyer;
    @ExcelProperty("下单时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date createdTime;

    @ExcelProperty("售后类型")
    private String afterSaleTypeStr;
    @ExcelProperty("售后类型")
    @ExcelIgnore
    private AfterSalesTypeEnum afterSaleType;

    @ExcelProperty("下单类型")
    private String orderTypeStr;
    @ExcelProperty("下单类型")
    @ExcelIgnore
    private OrderTypeEnum orderType;

    @ExcelProperty("订单状态")
    @ExcelIgnore
    private OrderStateEnum orderStatus;
    @ExcelProperty("订单状态")
    private String orderStatusStr;

    @ExcelProperty("售后状态")
    private String statusStr;
    @ExcelProperty("售后状态")
    @ExcelIgnore
    private AfterSaleAuditEnum status;

    @ExcelProperty("所属发货员")
    private String shipperName;
    @ExcelProperty("审核时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date afterAuditedTime;
    @ExcelProperty("订单价格")
    private Double orderPrice;
    @ExcelProperty("活动名称")
    private String actName;
    @ExcelProperty("所属代理商")
    private String agentName;

    @ExcelProperty("所属客服")
    private String customerName;
    @ExcelProperty("快递方式")
    private String expressName;

    @ExcelProperty("是否处理")
    private String isHandleStr;
    @ExcelProperty("是否处理")
    @ExcelIgnore
    private AfterSaleIsHandleEnum isHandle;


    public void setImg(String img){
        this.img = img;
        try {
            if (StrUtil.isNotEmpty(img)){
                this.imgUrl =new URL(GlobalConstant.IMG_PATH_URL +img+GlobalConstant.IMG_PATH_URL_SUFFIX);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    public void setOrderStatus(OrderStateEnum orderStatus){
        this.orderStatus = orderStatus;
        if(orderStatus != null){
            this.orderStatusStr = orderStatus.getDesp();
        }
    }

    public void setAfterSaleType(AfterSalesTypeEnum afterSaleType){
        this.afterSaleType = afterSaleType;
        if(afterSaleType != null){
            this.afterSaleTypeStr = afterSaleType.getDesp();
        }
    }

    public void setOrderType(OrderTypeEnum orderType){
        this.orderType = orderType;
        if(orderType != null){
            this.orderTypeStr = orderType.getDesp();
        }
    }

    public void setStatus(AfterSaleAuditEnum status){
        this.status = status;
        if(status != null){
            this.statusStr = status.getDesp();
        }
    }

    public void setIsHandle(AfterSaleIsHandleEnum isHandle){
        this.isHandle = isHandle;
        if(isHandle != null){
            this.isHandleStr = isHandle.getDesp();
        }
    }





}
